function toggleLayer(whichLayer)
{
if (document.getElementById)
{
// this is the way the standards work
var style2 = document.getElementById(whichLayer).style;
style2.display = style2.display? "":"block";
}
else if (document.all)
{
// this is the way old msie versions work
var style2 = document.all[whichLayer].style;
style2.display = style2.display? "":"block";
}
else if (document.layers)
{
// this is the way nn4 works
var style2 = document.layers[whichLayer].style;
style2.display = style2.display? "":"block";
}
}

function buttonlink(where) {
top.location = where
}

/*
 * Implements an expandable menu based on a HTML list
 * Author: Dave Lindquist (http://www.gazingus.org)
 */

window.onload = function() {

    initializeMenu("Db1tablesMenu", "Database1");
    initializeMenu("Db1table1Menu", "Db1table1");
    initializeMenu("Db1table2Menu", "Db1table2");
    initializeMenu("Db1table3Menu", "Db1table3");
    initializeMenu("Db1table4Menu", "Db1table4");

    initializeMenu("Db2tablesMenu", "Database2");
    initializeMenu("Db2table1Menu", "Db2table1");
    initializeMenu("Db2table2Menu", "Db2table2");
    initializeMenu("Db2table3Menu", "Db2table3");
    initializeMenu("Db2table4Menu", "Db2table4");

    initializeMenu("Db3tablesMenu", "Database3");
    initializeMenu("Db3table1Menu", "Db3table1");
    initializeMenu("Db3table2Menu", "Db3table2");
    initializeMenu("Db3table3Menu", "Db3table3");
    initializeMenu("Db3table4Menu", "Db3table4");

    initializeMenu("Db4tablesMenu", "Database4");
    initializeMenu("Db4table1Menu", "Db4table1");
    initializeMenu("Db4table2Menu", "Db4table2");
    initializeMenu("Db4table3Menu", "Db4table3");
    initializeMenu("Db4table4Menu", "Db4table4");

    initializeMenu("Db5tablesMenu", "Database5");
    initializeMenu("Db5table1Menu", "Db5table1");
    initializeMenu("Db5table2Menu", "Db5table2");
    initializeMenu("Db5table3Menu", "Db5table3");
    initializeMenu("Db5table4Menu", "Db5table4");

}

if (!document.getElementById)
    document.getElementById = function() { return null; }

function initializeMenu(menuId, databaseId) {
    var menu = document.getElementById(menuId);
    var database = document.getElementById(databaseId);

    if (menu == null || database == null) return;

    database.parentNode.style.backgroundImage = "url(plus.gif)";
    database.onclick = function() {
        var display = menu.style.display;
        this.parentNode.style.backgroundImage =
            (display == "block") ? "url(plus.gif)" : "url(minus.gif)";
        menu.style.display = (display == "block") ? "none" : "block";

        return false;
    }
}

var mmOpenContainer = null;
var mmOpenMenus = null;
var mmHideMenuTimer = null;

function MM_menuStartTimeout(hideTimeout) {
	mmHideMenuTimer = setTimeout("MM_menuHideMenus()", hideTimeout);	
}

function MM_menuHideMenus() {
	MM_menuResetTimeout();
	if(mmOpenContainer) {
		var c = document.getElementById(mmOpenContainer);
		c.style.visibility = "inherit";
		mmOpenContainer = null;
	}
	if( mmOpenMenus ) {
		for(var i in mmOpenMenus) {
			var m = document.getElementById(mmOpenMenus[i]);
			m.style.visibility = "hidden";			
		}
		mmOpenMenus = null;
	}
}

function MM_menuHideSubmenus(menuName) {
	if( mmOpenMenus ) {
		var h = false;
		var c = 0;
		for(var i in mmOpenMenus) {
			if( h ) {
				var m = document.getElementById(mmOpenMenus[i]);
				m.style.visibility = "hidden";
			} else if( mmOpenMenus[i] == menuName ) {
				h = true;
			} else {
				c++;
			}
		}
		mmOpenMenus.length = c+1;
	}
}

function MM_menuOverMenuItem(menuName, subMenuSuffix) {
	MM_menuResetTimeout();
	MM_menuHideSubmenus(menuName);
	if( subMenuSuffix ) {
		var subMenuName = "" + menuName + "_" + subMenuSuffix;
		MM_menuShowSubMenu(subMenuName);
	}
}

function MM_menuShowSubMenu(subMenuName) {
	MM_menuResetTimeout();
	var e = document.getElementById(subMenuName);
	e.style.visibility = "inherit";
	if( !mmOpenMenus ) {
		mmOpenMenus = new Array;
	}
	mmOpenMenus[mmOpenMenus.length] = "" + subMenuName;
}

function MM_menuResetTimeout() {
	if (mmHideMenuTimer) clearTimeout(mmHideMenuTimer);
	mmHideMenuTimer = null;
}

function MM_menuShowMenu(containName, menuName, xOffset, yOffset, triggerName) {
	MM_menuHideMenus();
	MM_menuResetTimeout();
	MM_menuShowMenuContainer(containName, xOffset, yOffset, triggerName);
	MM_menuShowSubMenu(menuName);
}

function MM_menuShowMenuContainer(containName, x, y, triggerName) {	
	var c = document.getElementById(containName);
	var s = c.style;
	s.visibility = "inherit";
	
	mmOpenContainer = "" + containName;
}
